<div id="side">
    <div id="add_content">
        <form action="/admin/create/" method="post">
            <label for="page_type">Create New:</label>
            <select name="page_type" id="page_type">
                <option value="" selected="selected">Page of type...</option>
                <? foreach($page_types as $class => $model): ?>
                    <option value="<?= $class ?>"><?= $class ?></option>
                <? endforeach; ?>
            </select>
            <input type="submit" name="create_new_page" value="Go" />
        </form>
    </div>
    <div id="content">
        <div class="tree_list">
            <?
                $right_stack = array(); // Used to measure parentage
            ?>
            <? foreach($tree as $key => $branch): ?>
                <? if(count($right_stack) && $branch->right_val > $right_stack[ count($right_stack) - 1 ]): ?>
                    <? array_pop($right_stack); ?>
                <? endif; ?>
                
                <? $right_stack[] = $branch->right_val ?>
                <div
                    class="branch_<?= $branch->parent_id ?>"
                    <? if(count($right_stack) > 1): ?>
                        style="display:none;"
                    <? endif; ?>
                >
                    <? for($i = 1; $i < count($right_stack); $i++): ?>
                        <img src="/images/admin/icons/transparent.png" alt="" width="16" height="16" />
                    <? endfor; ?>
                    <? if($branch->right_val - $branch->left_val > 1): ?>
                        <img
                            src="/images/admin/icons/bullet_toggle_plus.png"
                            alt="Expand Tree"
                            width="16"
                            height="16"
                            class="tree_icon clickable"
                            id="branch_<?= $branch->id ?>"
                        />
                    <? endif; ?>
                    <form action="/admin/ajax_get_edit/" method="post">
                        <input type="hidden" name="object_class" value="<?= $branch->get_class() ?>" />
                        <input type="hidden" name="object_id" value="<?= $branch->object_id ?>" />
                        <input type="hidden" name="object_version" value="<?= $branch->object_version ?>" />
                        <span>
                            <?= $branch->page_title ?>
                        </span>
                        <img
                            src="/images/admin/icons/page_edit.png"
                            alt="Edit Page"
                            width="16"
                            height="16"
                            class="edit_submit clickable"
                        />
                        <div class="br"></div>
                    </form>
                    <div class="br"></div>
                </div>
                
            <? endforeach; ?>
        </div>
        
        
    </div>
    <div class="br"></div>
</div>